<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    #toTop{width:100px;height:40px;line-height: 40px;text-align: center;position: fixed;right: 0;bottom: 100px;background: #ccc;}
    #toTop:hover{background: red;color: #fff;}
  </style>
</head>
<body>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <p>段落</p>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <img src="./imgs/baidu.png" alt="">
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <h2>二级标题</h2>
  <div id="toTop">回到顶部</div>
</body>
<script>

  var toTop = document.getElementById("toTop")
  toTop.onclick = function(){
    scrollTo({top: 0, behavior: 'smooth'})
  }
  
</script>
</html>